// 车险核保通过
import Vue from 'vue'
import {store} from '@/store/index'
import carPriceListMods  from '@/components/ivew_conf/car_price_list_mods'
import carPriceList  from '@/components/ivew_components/car_price_list/index.vue'
import {deepCopy} from '@/utils/tools'
import commonFn from './common_fn.ts'


let vueObj:any = new Vue();

const  examinePass = {

    title: '核保通过',
    icon: 'icon-complete-r',
    pag: 'carExaminePass',
    fn (){

        let data = store.state['carFormStore']['orderData'];
        let priceData = {
            jqPrice: 0,
            syPrice: 0,
            tax: 0,
        }
        let mods = carPriceListMods();

        // 构建弹窗
        vueObj.$Modal.confirm(
            {
                onOk (){

                    let _priceData = deepCopy(priceData);
                    
                    Object.keys(priceData).forEach(key =>{
                        priceData[key] = parseFloat(priceData[key])
                    })
                    
                    // 提交输入数据
                    store.dispatch('request', {
                        url: 'patch/order/id/status',
                        data: {

                            // 修改流程,
                            currentAction: '核保通过',
                            amount1: priceData.jqPrice,
                            amount2: priceData.syPrice,
                            amount3: priceData.tax,
                            massage: '',
                            
                        }
                    }

                ).then(success =>{
                    
                        if(success){

                            vueObj.$Notice.success({
                                title: '核保通过'
                            })

                            // 返回管理页
                            setTimeout(() =>{
                                commonFn('updateTable','outForm')
                            }, 500)
                        }
                    })
                    
                },
                render (h){
                    return h(carPriceList, {
                        props:{
                            data: priceData,
                            mods,
                        }
                    })
                }            
            }
        )
        
    }

}

export default examinePass